package com.example.courseselection;
import java.util.ArrayList;
import java.util.List;

public class Student {
    // 属性
    private String studentId;   // 学生编号
    private String name;        // 姓名
    private String gender;      // 性别
    private List<Course> selectedCourses;  // 所选课程列表

    // 构造方法
    public Student(String studentId, String name, String gender) {
        this.studentId = studentId;
        this.name = name;
        this.gender = gender;
        this.selectedCourses = new ArrayList<>();
    }

    // 选课方法
    public void selectCourse(Course course) {
        selectedCourses.add(course);
        System.out.println("学生 " + name + " 选择课程：" + course.getCourseName());
    }

    // 退课方法
    public void dropCourse(Course course) {
        if (selectedCourses.remove(course)) {
            System.out.println("学生 " + name + " 退选课程：" + course.getCourseName());
        } else {
            System.out.println("学生 " + name + " 未选该课程，无法退选！");
        }
    }

    // 打印课表方法
    public void printCourseSchedule() {
        System.out.println("=== 学生 " + name + "（编号：" + studentId + "）的课表 ===");
        System.out.println("课程编号\t课程名称\t上课地点\t上课时间\t授课教师编号");
        for (Course course : selectedCourses) {
            System.out.println(course.getCourseId() + "\t" + course.getCourseName() + "\t" + 
                               course.getLocation() + "\t" + course.getTime() + "\t" + 
                               course.getTeacherId());
        }
    }

    // Getter和Setter方法
    public String getStudentId() {
        return studentId;
    }

    public void setStudentId(String studentId) {
        this.studentId = studentId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getGender() {
        return gender;
    }

    public void setGender(String gender) {
        this.gender = gender;
    }

    public List<Course> getSelectedCourses() {
        return selectedCourses;
    }

    public void setSelectedCourses(List<Course> selectedCourses) {
        this.selectedCourses = selectedCourses;
    }

	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

}
